#ifndef __Orion_GPIO_h
#define __Orion_GPIO_h
#include "Orion_System.h"
#include "MR88FX02.h"
/*
	@ date: 2021-01-28
	  autor: mrsemi-AE department
*/
/*define special function number*/
#define Func0_spe 0
#define Func1_spe 1
#define Func2_spe 2
#define Func3_spe 3
/*define function 0 */
#define PA0_RXD2 	Func0_spe
#define PA1_TXD2 	Func0_spe
#define PA11_GTBRK	Func0_spe
#define PB3_TXD2	Func0_spe
#define PB4_RXD2	Func0_spe
#define PB5_TXD2	Func0_spe
#define PB6_RXD2	Func0_spe
#define PB7_TXD2	Func0_spe
#define PB8_RXD2	Func0_spe
#define PB11_TXD2	Func0_spe
#define PB12_RXD2	Func0_spe
#define PC4_TXD2	Func0_spe
#define PC5_RXD2	Func0_spe
#define PC6_GTBRK	Func0_spe
#define PC11_GTBRK	Func0_spe
#define PC12_RXD2	Func0_spe
#define PD0_TXD2	Func0_spe
/*define function 1 */
#define PB6_LED_C8	Func1_spe
#define PB7_LED_C7	Func1_spe
#define PB8_LED_C6  Func1_spe
#define PB9_LED_C5	Func1_spe
#define PB10_LED_C4	Func1_spe
#define PB11_LED_C3	Func1_spe
#define PB12_LED_C2	Func1_spe
#define PB13_LED_C1	Func1_spe
#define PB14_LED_S1	Func1_spe
#define PB15_LED_S2	Func1_spe
#define PC0_LED_S3	Func1_spe
#define PC1_LED_S4	Func1_spe
#define PC2_LED_S5	Func1_spe
#define PC3_LED_S6	Func1_spe
#define PC4_LED_S7	Func1_spe
#define PC5_LED_S8	Func1_spe
/*define function 2 */
#define PA0_SCL0	Func2_spe
#define PA1_SDA0	Func2_spe
#define PB1_SCL0	Func2_spe
#define PB2_SDA0	Func2_spe
#define PB7_SCL0	Func2_spe
#define PB8_SDA0	Func2_spe
#define PB11_FOUT	Func2_spe
#define PB13_SCL0	Func2_spe
#define PB14_SDA0	Func2_spe
#define PB15_SDA0	Func2_spe
#define PC1_SCL0	Func2_spe
#define PC2_SDA0	Func2_spe
#define PC3_SCL0	Func2_spe
#define PD1_SCL0	Func2_spe
#define PD2_SDA0	Func2_spe
#define PD3_SCL0	Func2_spe
/*define function 3 */
#define PA0_SCK0	Func3_spe
#define PA1_MISO0	Func3_spe
#define PA2_MOSI0	Func3_spe
#define PA10_SSN0	Func3_spe
#define PB2_SSN0	Func3_spe
#define PB4_SCK0	Func3_spe
#define PB5_MISO0	Func3_spe
#define PB6_MOSI0	Func3_spe
#define PB7_SCK0	Func3_spe
#define	PB8_MOSI0	Func3_spe
#define PB9_MISO0	Func3_spe
#define PB13_SCK0	Func3_spe
#define	PB14_MOSI0	Func3_spe
#define	PB15_MISO0	Func3_spe
#define	PC1_MISO0	Func3_spe
#define	PC2_MOSI0	Func3_spe
#define	PC3_SCK0	Func3_spe
#define	PC4_SCK0	Func3_spe
#define	PC5_MISO0	Func3_spe
#define	PC6_MOSI0	Func3_spe
#define	PC7_SSN0	Func3_spe
#define	PC8_MOSI0	Func3_spe
#define	PC9_MISO0	Func3_spe
#define	PC10_SCK0	Func3_spe
#define	PC11_SSN0	Func3_spe

#define PB14_SCL0	15
typedef enum{
    HSRC_DIV64 = 0, ///< lowest
    XTAL1_DIV64,
    XTAL2_DIV64,
    AHBCLK_DIV64,     
		APBCLK_DIV64,
		LSRC,
		CLK8K,
		ADCCLK,
		HSRC,
		XTAL1,
		XTAL2,
		HSRC_DIV256,
		SWCLK_AT,
		SWCLK_SIN,
		SVDO,
		RFU,			
} enumFout;

typedef enum{
	GPIO_INPUT_OFF_FLOATING=0,
	GPIO_INPUT_OFF_PD,
	GPIO_INPUT_OFF_PU,
	GPIO_INPUT_OFF_X,
	
	GPIO_INPUT_ON_FLOATING,
	GPIO_INPUT_ON_PD,
	GPIO_INPUT_ON_PU,
	GPIO_INPUT_ON_X,
	
	GPIO_OUTPUT_PP,
	GPIO_OUTPUT_PP_PD,
	GPIO_OUTPUT_PP_PU,
	GPIO_OUTPUT_PP_NOUSED,	//equal GPIO_OUTPUT_PP
	
	GPIO_OUTPUT_OD,
	GPIO_OUTPUT_OD_PD,
	GPIO_OUTPUT_OD_PU,
	GPIO_OUTPUT_OD_X,
	
	GPIO_AF_PP,
	GPIO_AF_PD,
	GPIO_AF_PP_PU,
	GPIO_AF_PP_NOUSE,
	
	GPIO_AF_OD,
	GPIO_AF_OD_PD,
	GPIO_AF_OD_PU,
	GPIO_AF_OD_X,
	
	GPIO_ANALOG
}enumPinType;

typedef enum{
   Pin_Num_0=0,
	Pin_Num_1,
	Pin_Num_2,
	Pin_Num_3,
	Pin_Num_4,
	Pin_Num_5,
	Pin_Num_6,
	Pin_Num_7,
	Pin_Num_8,
	Pin_Num_9,
	Pin_Num_10,
	Pin_Num_11,
	Pin_Num_12,
	Pin_Num_13,
	Pin_Num_14,
	Pin_Num_15
} enumPinNum;
typedef enum{
	Func0=0,
	Func1,
	Func2,
	Func3,
	Func4_GT0_CH1,
	Func5_GT0_CH2,
	Func6_GT1_CH1,
	Func7_GT1_CH2,
	Func8_GT2_CH1,
	Func9_GT2_CH2,
	Func10_UART0_RX,
	Func11_UART0_TX,
	Func12_UART1_RX,
	Func13_UART1_TX,
	Func14_BEEP0,
	Func15_BEEP1
} enumPinFunc;

void GPIO_Initial(GPIO_Type* GPIOX,enumPinNum PIN_Num,enumPinType conf,enumPinFunc funx);
void GPIO_Reset(GPIO_Type* GPIOX,enumPinNum PIN_Num);
void GPIO_Set(GPIO_Type* GPIOX,enumPinNum PIN_Num);
BitStatue GPIO_Get_DO_statue(GPIO_Type* GPIOX,enumPinNum PIN_Num);
BitStatue GPIO_Get_DI_statue(GPIO_Type* GPIOX,enumPinNum PIN_Num);
void GPIO_Fout(enumFout fsrc); //initial function is not needed
#endif

